As of iPadOS 15, this issue has still not been resolved by Apple. Good news though! The developer community has made a swift package called SwiftUI-Introspect.. After adding the package to your project (which they say is built to use in Production apps, not just for development purposes), import Introspect in your SwiftUI view and at the end of your sidebar list, add this modifier:
List {
NavigationLink(destination: DemoView()) {
Text("Demo")
}
}
.listStyle(.sidebar)
.navigationTitle("Demo")
.introspectTableView { inspect in
inspect.backgroundColor = .secondarySystemBackground
}
Unlike other methods, this method only applies the .secondarySystemBackground to the sidebar and not the Main or Secondary Views!
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: